﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace MvcHeatloss.Models
{
    public partial class Floor
    {
        public ProjectEntities db = new ProjectEntities();
        
        public Floor(double length, double width, string type, int temp)
        {
            FloorArea = CalcHeatoss.CalcArea(length , width);
            FloorType = type;
            FloorUValue = (double)db.UValues.Where(d => d.Description == type).Select(u => u.UValue1).First();
            FloorTemp = temp;
            FloorHeatloss = CalcHeatoss.FabricHeatloss(this.FloorUValue, this.FloorArea, this.FloorTemp);
        }
        public Floor(): base()
        {
        }

        public string FloorType { get; set; }
        
        public int FloorTemp { get; set; }
        
        public double FloorUValue { get; set; }

        public double FloorArea { get; set; }

        double floorHeatloss;
        public double FloorHeatloss 
        {
            get
            {
                return floorHeatloss;
            }
            set
            {
                floorHeatloss = CalcHeatoss.FabricHeatloss(this.FloorUValue, this.FloorArea, this.FloorTemp);
            }
        }
    }
}